﻿using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using WroxGallery.Models;
using WroxGallery.Models.Implementations;

namespace WroxGallery.Tests.Models
{
    /// <summary>
    /// Summary description for ConfigurationRepositoryTest
    /// </summary>
    [TestClass]
    public class XmlConfigurationRepositoryTest
    {
        [TestMethod]
        [DeploymentItem(@"App_Data\TestingConfig.xml", "App_Data")]
        public void XmlConfigurationRepository_Can_Get_Gallery_Title()
        {
            XmlConfigurationRepository repository = new XmlConfigurationRepository(@"App_Data\TestingConfig.xml");
            string galleryName = repository.GalleryName;
            Assert.AreEqual("Gallery Name", galleryName);
        }

        [TestMethod]
        [DeploymentItem(@"App_Data\TestingConfig.xml", "App_Data")]
        public void XmlConfigurationRepository_Can_Get_Flickr_UserName()
        {
            XmlConfigurationRepository repository = new XmlConfigurationRepository(@"App_Data\TestingConfig.xml");
            string userName = repository.FickerUserName;
            Assert.AreEqual("userId@12345", userName);
        }

        [TestMethod]
        [DeploymentItem(@"App_Data\TestingConfig.xml", "App_Data")]
        public void XmlConfigurationRepository_Can_Get_Configuration_Object()
        {
            XmlConfigurationRepository repository = new XmlConfigurationRepository(@"App_Data\TestingConfig.xml");
            GalleryConfiguration configuration = repository.Config;
            Assert.IsNotNull(configuration);
        }

        [TestMethod]
        [DeploymentItem(@"App_Data\TestingConfig.xml", "App_Data")]
        public void XmlConfigurationRepository_Can_Save_New_Configuration()
        {
            XmlConfigurationRepository repository = new XmlConfigurationRepository(@"App_Data\TestingConfig.xml");
            repository.Config.About = "This Is not the same about";
            repository.Store();
            XmlConfigurationRepository repository1 = new XmlConfigurationRepository(@"App_Data\TestingConfig.xml");
            Assert.AreEqual("This Is not the same about",repository1.About);
        }

    }
}
